home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 076-100 / 085 / lowmem / client.h < prev    next >
C/C++ Source or Header  |  1995-03-13  |  4KB  |  130 lines

  1. Article 5402 of comp.sys.amiga:
  2. Path: mcdsun!noao!hao!husc6!cmcl2!rutgers!sri-spam!mordor!lll-tis!ptsfa!lll-lcc!well!perry
  3. From: perry@well.UUCP (Perry S. Kivolowitz)
  4. Newsgroups: comp.sys.amiga
  5. Subject: Low Memory Server From ASDG
  6. Keywords: publicly redistributable shared library
  7. Message-ID: <3286@well.UUCP>
  8. Date: 11 Jun 87 20:57:55 GMT
  9. Lines: 117
  10.  
  11. As part of the development of FacII - I have written a general purpose
  12. low-memory ``server.'' That is,  an  agent  which will allow arbitrary
  13. processes to register  with  it  their  desire to be notified when the
  14. system is low on memory (actually - whenever an AllocMem fails).
  15.  
  16. The actual implementation is as a shared library (about 1K) which con-
  17. tains two library calls. These are:
  18.  
  19.     RegLowMemReq - Register Low Memory Request
  20.  
  21.     res = RegLowMemReq(PortName , LowMemMsgPtr);
  22.     d0                    a0           a1
  23.  
  24.     DeRegLowMemReq - Deregister Low Memory Request
  25.  
  26.     (void) DeRegLowMemReq(PortName);
  27.                  a0
  28.  
  29. Below is the include file you would use to program with the low-memory
  30. server.  It contains  the conditions under which we are releasing this
  31. software for public redistribution (we retain all rights and allow re-
  32. distribution for non-commercial  purposes  only - commercial redistri-
  33. is granted by licensing agreement whcih says simply that you'll credit
  34. us  somewhere  in  your  documentation and will send us a copy of your
  35. product).
  36.  
  37. The low-memory server library  is  written completely in assembly lan-
  38. guage and is  quite  small and efficient. It will properly expunge it-
  39. self upon receiving its last closelibrary.
  40.  
  41. It will accomodate an arbitrarily large  number  of  clients  and will
  42. perform consistency checks  before  actually sending a message to help
  43. prevent the possibility of a message being sent to nowhere.
  44.  
  45. In the next  few days I will post the library itself, full programming
  46. examples, and full programming documentation.
  47.  
  48. And by the way - FaccII is coming along VERY well. Many of the comments
  49. made here on usenet have been incorporated into the product.
  50.  
  51. Cheers, 
  52.  
  53. Perry S. Kivolowitz - ASDG Incorporated - (201) 563-0529
  54.  
  55. -----cut here----
  56.  
  57. /*
  58. **    :ts=8
  59. **
  60. **    low-mem.h
  61. **
  62. **    Copyright 1987 By ASDG Incorporated - All Rights Reserved
  63. **    May  be  freely redistributed for non-commercial purposes 
  64. **    provided this  message  retains intact. Available for use
  65. **    in commercial  products for VERY minimal concession. Con-
  66. **    tact ASDG Incorporated at  (201) 563-0529. Use in commer-
  67. **    cial products without  authorization of ASDG Incorporated
  68. **    shall be viewed as copyright infringement and piracy.
  69. **
  70. **    For commercial applications of the low-memory server ASDG
  71. **    will grant perpetual use licenses provided that:
  72. **        a) We are credited  somewhere  in your documenta-
  73. **           tion.
  74. **        b) You send us a copy of the application.
  75. **        c) You pay a  very small  administrative fee  not
  76. **           exceeding $50 if we find it necessary.
  77. **
  78. **    Author:    Perry S. Kivolowitz
  79. */
  80.  
  81. /*
  82. **    To use the low-memory server you must allocate one of these
  83. **    structures.  When a  low memory  condition exists, the low-
  84. **    memory server will look for  the message port you specified
  85. **    in the call to RegLowMemReq.  If the message port is found,
  86. **    the low-memory  server will  examine the LoeMemMsg you sup-
  87. **    plied a pointer to in the call to RegLowMemReq.
  88. **
  89. **    If the low-memory server finds something other than LM_CON-
  90. **    DITION_ACKNOWLEDGED, it will not send you a message. There-
  91. **    fore you should initialize this field with that value.
  92. **
  93. **    This scheme  is  used to  ensure that the low-memory server
  94. **    does not reuse the same LowMemMsg (which you supply).  This
  95. **    scheme allows the low-memory server to not wait for a Reply
  96. **    which could be deadly if none was forthcoming from your ap-
  97. **    plication.
  98. */
  99.  
  100. struct LowMemMsg {
  101.     struct Message lm_msg;
  102.     long lm_flag;
  103. };
  104.  
  105.  
  106. /*
  107. **    values for lm_flag
  108. */
  109.  
  110. #define    LM_LOW_MEMORY_CONDITION        0x00000000
  111. #define    LM_CONDITION_ACKNOWLEDGED    (('A'<<24)|('S'<<16)|('D'<<8)|'G')
  112.  
  113. /*
  114. **    useful defines as in:
  115. **
  116. **    lmptr = (LMPtr) AllocMem(SizeOfLMMsg , 0L);
  117. */
  118.  
  119. #define    SizeOfLMMsg    sizeof(struct LowMemMsg)
  120. #define    LMMPtr        struct LowMemMsg *
  121.  
  122. /*
  123. **    Meaning of Error Returns coming back from RegLowMemReq
  124. */
  125.  
  126. #define    LM_BADNAME    -1    /* duplication of port name */
  127. #define    LM_NOMEM    -2    /* memory allocation failed */
  128.  
  129.  
  130.